package business.impls.xml;

import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import java.util.HashMap;

/**
 * User: Programmer
 * Date: 12.04.2006
 * Time: 14:12:21
 */
public class XML_Parser extends DefaultHandler{

    private HashMap<Integer, Integer> map = new HashMap();
    private Integer egCount = 0;
    private Integer ourID = 0;
    private Integer fbsID = 0;

    public HashMap<Integer, Integer> getMap() {
        return map;
    }

    public Integer getEgCount() {
        return egCount;
    }

    public void startElement(String uri, String localName, String qName, Attributes amap) throws SAXException{

        if(localName.equalsIgnoreCase("subj")){
            int len = amap.getLength();
            for(int i=0;i<len;i++){
                ourID = Integer.valueOf(amap.getValue("ourID"));
                fbsID = Integer.valueOf(amap.getValue("fbsID"));
                map.put(ourID,fbsID);
            }
        }

        if(localName.equalsIgnoreCase("egCount")){
            egCount = Integer.valueOf(amap.getValue("count"));
        }

    }

}
